﻿using System;
using System.Linq;
using Framework.Poco;
using Shell.DomainDot;
namespace Framework.Domain
{
    /// <summary>
    /// 文章分类更新器
    /// </summary>
    public class UpdateCategory : DomainDotBase
    {        
        /// <summary>
        /// 所有的文章分类
        /// </summary>
        public WithAll<Category> Categoryies { get; set; }

        /// <summary>
        /// 更新分类
        /// </summary>
        public void Update(Category instance)
        {
            var original = this.Categoryies.SingleOrDefault(i => i.Id.Equals(instance.Id));
            if (original == null)
            {
                return;
            }
            PocoUtils.AssignProperty<Category>(instance, original, typeof(Guid));
            this.Categoryies.Submit();
        }
    }
}
